<template>
  <section>
    <product-create :formData.sync="createForm" @cancelCreate="cancel" @okCreate="ok" />
  </section>
</template>

<script>
export default {
  components: {
            'product-create': () => import('../../components/Product/create'),
  },
  data() {
    return {
      createForm: {
          product_id: 0,
          is_view: false,
          product_no: "",
          card_type: 0,
      },
      from: "",
      pageNum: this.$route.query.pageNum || 1,
      pageSize: this.$route.query.pageSize || 20,
      keyword: this.$route.query.keyword,
      cateId: this.$route.query.cateId,
      parentCateId: this.$route.query.parentCateId,
      card_type: this.$route.query.card_type,
    };
  },
  mounted() {
  },
        created() {
            this.createForm.product_no = this.$route.query.no;
            this.createForm.card_type = this.$route.query.card_type;
            this.from = this.$route.query.from;
        },

  methods: {
    cancel() {
        // this.$router.push({path: '/company/vendors'});
    },
    ok() {
      if(this.from) {
        // this.$router.push({name: this.from});
        let url = "/goods_fuli" 
            + "?pageSize=" + encodeURIComponent(this.pageSize)
            + "&pageNum=" + encodeURIComponent(this.pageNum);
        if(this.keyword) {
            url += "&keyword=" + encodeURIComponent(this.keyword);
        }
        if(this.parentCateId) {
            url += "&parentCateId=" + this.parentCateId;
        }
        if(this.cateId) {
            url += "&cateId=" + this.cateId;
        }
        this.$router.push(url)
      } else {
        this.$router.push({path: '/goods_fuli'});
      }
    },
  }
};
</script>
